﻿namespace Hidistro.UI.SaleSystem.CodeBehind
{
    using Hidistro.Core;
    using Hidistro.Membership.Context;
    using Hidistro.UI.Common.Controls;
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    [ParseChildren(true)]
    public class VLogin : VshopTemplatedWebControl
    {
        private string openId;
        //protected HyperLink hlinkLogout;
        protected override void AttachChildControls()
        {
            //this.openId = this.Page.Request.QueryString["sessionId"];


            //if (string.IsNullOrEmpty(this.openId))
            //{
            //    this.Page.Response.Redirect("/Vshop/Default.aspx");
            //}
            //else
            //{
            //    Member userByOpenId = Users.GetUserByOpenId(this.openId) as Member;
            //    Member user = HiContext.Current.User as Member;
            //    if ((user != null) && (string.IsNullOrEmpty(user.OpenId) && (userByOpenId == null)))
            //    {
            //        user.OpenId = this.openId;
            //        Users.UpdateUser(user);
            //        userByOpenId = user;
            //    }
            //    if (userByOpenId != null)
            //    {
            //        HttpCookie cookie = new HttpCookie("Vshop-Member")
            //        {
            //            Value = Globals.UrlEncode(userByOpenId.Username),
            //            Expires = DateTime.Now.AddYears(1)
            //        };
            //        HttpContext.Current.Response.Cookies.Add(cookie);
            //        this.Page.Response.Redirect("/Wapshop/Default.aspx");
            //    }
            //    PageTitle.AddSiteNameTitle("登录");
            //}
            PageTitle.AddSiteNameTitle("登录");
        }

        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "skin-VLogin.html";
            }
            base.OnInit(e);
        }
    }
}

